package cn.edu.seu.ssny.controller.web;

import cn.edu.seu.ssny.common.R;
import cn.edu.seu.ssny.controller.BaseController;
import cn.edu.seu.ssny.entity.Project;
import cn.edu.seu.ssny.entity.SysClass;
import cn.edu.seu.ssny.service.ISysClassService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/sysclass")
public class SysClassController extends BaseController {

    @Autowired
    private ISysClassService sysClassService;

    /**
     * 功能描述：
     * <根据项目ID返回该项目的所有系统类名
     *
     * @return
     */
    @ResponseBody
    @GetMapping("/list")
    public R findAllSysClass(HttpSession session) {
        Project project = super.getCurrProject(session);
        Long projectId = Long.valueOf(project.getId());
        List<SysClass> sysClasses = sysClassService.findAllByProjectId(projectId);
        Map<String, Object> data = new HashMap<>();
        data.put("sysclasses", sysClasses);
        return R.ok().data(data);
    }

}
